import 'package:flutter/material.dart';
import 'package:safflow/global_config.dart';
import '../home/search_page.dart';

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  Widget barSearch() {
    // 搜索最外层布局
    return Container(
      child: Row(
        children: [
          Expanded(
              // 搜索框触发后
              child: FlatButton.icon(
                  onPressed: () {
                    Navigator.of(context)
                        .push(new MaterialPageRoute(builder: (context) {
                      return SearchPage();
                    }));
                  },
                  // 搜索图片
                  icon: Icon(
                    Icons.search,
                    color: GlobalConfig.fontColor,
                    size: 16,
                  ),
                  // 搜索狂hint文字
                  label: Text(
                    "坚果R1摄像头损坏",
                    style: TextStyle(color: GlobalConfig.fontColor),
                  ))),
          Container(
            decoration: BoxDecoration(
                border: BorderDirectional(
                    start:
                        BorderSide(color: GlobalConfig.fontColor, width: 1))),
            height: 14,
            width: 1,
          ),
          // new Container(
          //     child: new FlatButton.icon(
          //       onPressed: (){
          //         Navigator.of(context).push(new MaterialPageRoute(
          //             builder: (context) {
          //               return new AskPage();
          //             }
          //         ));
          //       },
          //       icon: new Icon(
          //           Icons.border_color,
          //           color: GlobalConfig.fontColor,
          //           size: 14.0
          //       ),
          //       label: new Text(
          //         "提问",
          //         style: new TextStyle(color: GlobalConfig.fontColor),
          //       ),
          //     )
          // )
        ],
      ),
      decoration: BoxDecoration(
          borderRadius: BorderRadius.all(Radius.circular(4)),
          color: GlobalConfig.searchBackgroundColor),
    );
  }

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
        length: 3,
        child: Scaffold(
          appBar: AppBar(
            title: barSearch(),
            bottom: TabBar(
                labelColor: GlobalConfig.dark == true
                    ? new Color(0xFF63FDD9)
                    : Colors.blue,
                unselectedLabelColor:
                    GlobalConfig.dark == true ? Colors.white : Colors.black,
                tabs: [
                  Tab(
                    text: "关注",
                  ),
                  Tab(
                    text: "推荐",
                  ),
                  Tab(
                    text: "热榜",
                  )
                ]),
          ),
        ));
  }
}
